<?
	include '../inc.php';
	// importing language (
		$rawsettings = fetch("SELECT * FROM settings;");
		$settings = array(); foreach($rawsettings as $i) $settings[$i[0]] = $i[1];
		include '../langs/'.$settings['lang'].'.php';
	// ) importing language
	$r = fetch('SELECT * FROM users WHERE name LIKE "'.$_POST['u'].'";');
	if(count($r)==0) {
		echo '{r:"fail",title:"'.$lang['badNameTitle'].'",text:"'.$lang['badNameText'].'",hotlink:"'.$lang['backToForm'].'"}';
	} else {
		if($r[0]['pass']!=md5($_POST['p'])) {
			echo '{r:"fail",title:"'.$lang['badPassTitle'].'",text:"'.$lang['badPassText'].'",hotlink:"'.$lang['backToForm'].'"}';
		} else {
			include 'createSession.php';
			createSession($r[0]);
			echo '{r:"ok",u:"'.$r[0]['name'].'",p:"'.$r[0]['permission'].'"}';
		}
	}
?>